package com.cdn.auth.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashSet;
import java.util.Set;

/**
 * 蔡定努
 * 2024/06/28 19:15
 */
@ConfigurationProperties(prefix = "cauth")
public class CAuthProperties {


    /**
     * 匿名访问路径
     */
    private Set<String> ignorePaths = new HashSet<>();


    private Jwt jwt = new Jwt();

    public Jwt getJwt() {
        return jwt;
    }

    public void setJwt(Jwt jwt) {
        this.jwt = jwt;
    }

    public Set<String> getIgnoresPath() {
        return ignorePaths;
    }

    public void setIgnoresPath(Set<String> ignorePaths) {
        this.ignorePaths = ignorePaths;
    }


    public String getSecret() {
        return jwt.getSecret();
    }

    public String getHeaderKey() {
        return jwt.getHeaderKey();
    }

    public Long getExpireTime() {
        return jwt.getExpireTime();
    }

    public Long getTimeInterval() {
        return jwt.getRefreshTimeInterval();
    }


    static class Jwt {

        /**
         * 秘钥
         */
        private String secret = "secret";

        /**
         * 请求头key
         */
        private String headerKey = "Authorization";

        /**
         * token 过期时间(单位:毫秒)
         */
        private Long expireTime = 60000L;

        /**
         * 距离过期多少秒后自动刷新token,单位ms，默认15分钟
         */
        private Long refreshTimeInterval = 15 * 60 * 1000L;

        public Long getExpireTime() {
            return expireTime;
        }

        public void setExpireTime(Long expireTime) {
            this.expireTime = expireTime;
        }

        public String getHeaderKey() {
            return headerKey;
        }

        public void setHeaderKey(String headerKey) {
            this.headerKey = headerKey;
        }

        public String getSecret() {
            return secret;
        }

        public void setSecret(String secret) {
            this.secret = secret;
        }

        public Long getRefreshTimeInterval() {
            return refreshTimeInterval;
        }

        public void setRefreshTimeInterval(Long refreshTimeInterval) {
            this.refreshTimeInterval = refreshTimeInterval;
        }
    }
}
